package com.databaseprotect;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.io.File;

public class User extends MainActivity{
    public static User instance = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user);
        User_Status=true;
        instance = this;
        if(m_user_type.equals("admin")){
            LinearLayout layout=findViewById(R.id.user_buttom);
            layout.setVisibility(View.VISIBLE);
            if (status==true){
                TextView model=(TextView)findViewById(R.id.model);
                model.setText("用户模式");
            }
        }
        String username=m_username;
        if(username!=""){
            TextView username_text=(TextView)findViewById(R.id.user_name);
            username_text.setText(username);
        }
    }
    public void tologin(View v){
        Intent intent=new Intent(this,Login.class);
        startActivity(intent);
    }
    public void toSetImage(View v){
        if(m_username.equals("")) tologin(v);
        else {
        }
    }

    public void outlogin(View v){
        if(m_username.equals("")) Toast.makeText(this, "请先登录", Toast.LENGTH_SHORT).show();
        else {
            m_user_type = "user";
            m_username = "";
            status=false;
            finish();
            Intent intent = new Intent(this, User.class);
            startActivity(intent);
        }
    }
    public void toAdmin(View v){
        if (status==false) {
            status=true;
            Intent intent = new Intent(this, Admin_MainActivity.class);
            startActivity(intent);
            finish();
        }else{
            status=false;
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }
}
